RPI3B+尝试新方法运行Javafx

技术经验 dingxiao 阅读数:118934 2018年7月16日 15:39

RPI3B+尝试新方法运行Javafx

尝试采用最新JDK和JavaFX SDK在RPI3B+上运行

参考网址:Using JavaFX on Raspberry Pi 3 with Gluon

  • Installation of Java

Download the ‘Linux ARM 32 Hard Float ABI’ Java SE Development kit from the Oracle website. I downloaded jdk-8u144-linux-arm32-vfp-hflt.tar.gz.

  Copy it to the device using SCP:
scp jdk-8u144-linux-arm32-vfp-hflt.tar.gz pi@192.168.1.60:
(Replacing 192.168.1.60 with the IP address of your own device of course)

Now unzip the copied file:
tar zxf jdk-8u144-linux-arm32-vfp-hflt.tar.gz

Move the JDK to a location of your choice. I choose /opt and also created a symbolic link for future updates:
sudo mv ./jdk1.8.0_144/ /opt/
sudo ln -s /opt/jdk1.8.0_144/ /opt/jdk8

Check if Java works by checking the version of the java executable:

pi@raspberrypi:~ $ /opt/jdk8/bin/java -version
java version "1.8.0_144"
Java(TM) SE Runtime Environment (build 1.8.0_144-b01)
Java HotSpot(TM) Client VM (build 25.144-b01, mixed mode)
  • Installation of JavaFX

Although Java 8 contains JavaFX by default, it does not contain what is needed to have JavaFX applications running on the Raspberry Pi. For this, you need the Gluon JavaFX Embedded SDK. Download it from JavaFX Embedded SDK

  Copy it to the Pi:
scp armv6hf-sdk-8.60.9.zip pi@192.168.1.60:

On the Pi itself, unzip it and copy the unzipped files onto the just installed Java SDK. Take note of what parts need to be copied where!
pi@raspberrypi:~ $ unzip armv6hf-sdk-8.60.9.zip
pi@raspberrypi:~ $ cp armv6hf-sdk/rt/lib/ext/jfxrt.jar /opt/jdk8/jre/lib/ext/
pi@raspberrypi:~ $ cp armv6hf-sdk/rt/lib/arm/* /opt/jdk8/jre/lib/arm/
pi@raspberrypi:~ $ cp armv6hf-sdk/rt/lib/javafx.platform.properties /opt/jdk8/jre/lib/
pi@raspberrypi:~ $ cp armv6hf-sdk/rt/lib/javafx.properties /opt/jdk8/jre/lib/
pi@raspberrypi:~ $ cp armv6hf-sdk/rt/lib/jfxswt.jar /opt/jdk8/jre/lib/
  • Running JavaFX

run script

  sudo /opt/jdk8/bin/java -jar Helloworld.jar

实际运行情况

原有runfxapp运行环境无需破坏,两种运行方式可共存。

sudo nano /etc/profile无需修改。

  • 运行runfxapp情况运行runfxapp脚本在点击文本输入框后会大量报nio错误。

  • 运行/opt/jdk8/bin/java情况运行opt脚本在点击文本输入框后只报Cannot create resources。

  • 比较两者

目前看来两种方法均没有达到预期的效果,但从程度上分析opt脚本方法稍比runfxapp方法好些,后期还需探索其他方法或对其进行优化。

Javafx最新动态

status of java on raspbian

Liberica JDK for Raspberry PiVersions: 10, 9.0.4, 9.01Liberica JDK for Raspberry Pi

Release Notes: "Liberica is a 100% open-source Java 10 implementation for Raspberry Pi. It is built from OpenJDK which BellSoft contributes to, is thoroughly tested and passed the JCK provided under the license from OpenJDK. It also contains JavaFX 10 with hardware-accelerated EGL support and Device IO API as additional modules. We currently provide two binaries suitable for different Raspberry Pi versions and OS combinations"liberica-release-notes

B4J - Desktop, Server and Raspberry Pi

RFID-RC522 implementation using WiringPI library

LiangYuen/Pi4j-RC522

3'5'' TFT Touch screen doesn't display JavaFX apps

Raspberry Pi B4J UI Applications with Liberica JDK


captcha
    暂无评论